package study.source.common.util;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ExcelReaderJxl {
	
	private Workbook workbook = null;
	Sheet sheet = null;
	ArrayList<String[]> data = null;
	String[] dataSt = null;
	
	public ExcelReaderJxl(){
		
	}
	
	public ExcelReaderJxl(File excelFile) throws BiffException, IOException{
		this.workbook = Workbook.getWorkbook(excelFile);
		this.sheet = workbook.getSheet(0);
	}

	public List<String[]> excelRead() {
		data = new ArrayList<String[]>();
		for(int i=0; i<sheet.getRows(); i++){
			dataSt = new String[sheet.getColumns()];
			for(int j=0; j<sheet.getColumns(); j++){
				Cell cell = sheet.getCell(j, i);
				dataSt[j] = cell.getContents();
				System.out.print(cell.getContents()+"\t");
			}
			data.add(dataSt);
			System.out.println();
		}
		return data;
	}
	
}
